package cn.zynworld.saas.user.api.result;

import java.io.Serializable;

/**
 * Created by zhaoyuening on 2018/1/18.
 */
public class ResultBean<T> implements Serializable{

    private T data = null;
    private int status = 400;
    private boolean success = false;
    private String msg;

    public static final ResultBean SUCCESS = new ResultBean().setSuccess(true).setStatus(200);
    public static final ResultBean FAIL = new ResultBean().setSuccess(false).setStatus(400);

    public String getMsg() {
        return msg;
    }

    public ResultBean setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public T getData() {
        return data;
    }

    public ResultBean setData(T data) {
        this.data = data;
        return this;
    }

    public int getStatus() {
        return status;
    }

    public ResultBean setStatus(int status) {
        this.status = status;
        return this;
    }

    public boolean isSuccess() {
        return success;
    }

    public ResultBean setSuccess(boolean success) {
        this.success = success;
        return this;
    }

    public static <T> ResultBean<T> SUCCESS(T data){
        return new ResultBean<T>().setSuccess(true).setStatus(200).setData(data);
    }
    public static <T> ResultBean<T> SUCCESS(){
        return SUCCESS(null);
    }

    public static <T> ResultBean<T> FAIL(){
        return new ResultBean<T>().setSuccess(false).setStatus(400);
    }

}
